package lyc.springcloud.admin.utils;

import lombok.Data;

@Data
public class CommonResClass {
    private int code = 0;
    private String msg;
    private Object data;

    /**
     * success
     * 不传参
     * */
    public static CommonResClass success() {
        return new CommonResClass(CommonResInfo.SUCCESS.getCode(), CommonResInfo.SUCCESS.getMsg());
    }
    /**
     * success
     * 传参---msg
     * */
    public static CommonResClass success(String msg) {
        return new CommonResClass(CommonResInfo.SUCCESS.getCode(), msg);
    }
    /**
     * success
     * 传参---data
     * */
    public static CommonResClass success(Object data) {
        return new CommonResClass(CommonResInfo.SUCCESS.getCode(), CommonResInfo.SUCCESS.getMsg(), data);
    }

    /**
     * failure
     * 不传参
     * */
    public static CommonResClass failure() {
        return new CommonResClass(CommonResInfo.FAIL.getCode(), CommonResInfo.FAIL.getMsg());
    }
    /**
     * failure
     * 传参---msg
     * */
    public static CommonResClass failure(String msg) {
        return new CommonResClass(CommonResInfo.FAIL.getCode(), msg);
    }
    /**
     * failure
     * 传参---data
     * */
    public static CommonResClass failure(Object data) {
        return new CommonResClass(CommonResInfo.FAIL.getCode(), CommonResInfo.FAIL.getMsg(), data);
    }



    private CommonResClass(int code) {
        super();
        this.code = code;
    }
    private CommonResClass(String msg) {
        super();
        this.msg = msg;
    }
    private CommonResClass(Object data) {
        super();
        this.data = data;
    }
    private CommonResClass(int code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }
    private CommonResClass(int code, String msg, Object data) {
        super();
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}
